import Vue from 'vue'
import Vuex from 'vuex'

import menus from "./modules/menus";

Vue.use(Vuex)

export default new Vuex.Store({
  state:{ //这里放全局参数
    token:''
  },
  mutations:{ //这里是set方法
    SET_TOKEN: (state,token) => {
      state.token=token
      localStorage.setItem("token",token)
    },

    resetState: (state) => {  //退出登录时清除信息
      state.token="";
      menus.state.menuList=[];
      menus.state.permList=[];
      menus.state.hasRoute=false;
      menus.state.editableTabsValue="Index";
      localStorage.clear();
      sessionStorage.clear();
      menus.state.editableTabs=[{
        title: '首页',
        name: 'Index',
      }];
    },

    clearLocalStoreToken: ()=>{
      localStorage.removeItem("token")
    }
  },
  getters:{ //这里是get方法

  },
  actions:{

  },
  modules:{
    menus //引入此模块
  }
})
